package Game;

import java.awt.Graphics2D;
import java.util.LinkedList;

public class ItemManager
{
	private static LinkedList<Item> lItem;
	
	private static boolean added_removed;
	
	private ItemManager() {}
	
	public static void Setup()
	{
		lItem = new LinkedList<Item>();
	}
	
	public static void Add(Item item)
	{		
		lItem.add(item);
		
		added_removed = true;
	}
	
	public static void Remove(Item item)
	{
		lItem.remove(item);
		
		added_removed = true;
	}
	
	public static void Update()
	{
		if(lItem != null)
		{
			for(Item item : lItem)
			{
				item.Update();
				
				if(item.visible == false)
				{
					Remove(item);
				}
				
				if(added_removed)
				{
					added_removed = false;
					break;
				}
			}
		}
	}
	
	public static void Draw(Graphics2D g2d)
	{
		if(lItem != null)
		{
			for(Item item : lItem)
			{
				item.Draw(g2d);
				
				if(added_removed)
				{
					added_removed = false;
					break;
				}					
			}
		}
	}
}
